﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace 天上人和酒店管理
{
    public partial class RoomNum : Form
    {
        public RoomNum()
        {
            InitializeComponent();
            HuoQuKeFang();
        }

        private void RoomNum_Load(object sender, EventArgs e)
        {

        }

        private void HuoQuKeFang()
        {
            int count = 0;
           
            using (MySqlConnection conn = new MySqlConnection("server=localhost;port=3306;user=root;password=615122;database=天上人和酒店管理;Charset=utf8;"))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("", conn);//创建SQL执行命令
                cmd.Connection = conn;
                cmd.CommandText = "select * from 客房数据表";//Sql 执行命令绑定语句
                DataTable dt = new DataTable();//单个数据表*-
                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                da.Fill(dt);
                //MessageBox.Show(dt.Rows.Count.ToString());
                //foreach (DataRow dr in dt.Rows)
                //{
                //    //MessageBox.Show(dr["房号"] + " " + dr["房价"]);
                //    //MessageBox.Show(tableLayoutPanel1.GetControlFromPosition(0, count++)+"");
                //    //label2.Text = dr["房号"].ToString();
                //    Control PanelControl = tableLayoutPanel1.GetControlFromPosition(0, count++);
                //}
                for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
                {
                    for (int j = 0; j < tableLayoutPanel1.ColumnCount; j++)
                    { 
                        Control PanelControl =  tableLayoutPanel1.GetControlFromPosition(j, i);//获取到表格中所有的控件

                        foreach (var p in PanelControl.Controls)
                        {   
                           // MessageBox.Show(p.ToString());
                        }
                    }
                }
            }

                
            
        }
        //罗
    }
}
